// import { get_image } from '../utils'

const HrEmployee = {
  _description: '员工',
  _name: 'hr.employee',
  _fields: {
    name: { type: 'char', string: '姓名' },
    mobile_phone: { type: 'char', string: '办公手机' },
    work_phone: { type: 'char', string: '办公电话' },
    work_email: { type: 'char', string: '办公Email' },
    work_location: { type: 'char', string: '工作地点' },

    department_id: { type: 'many2one', string: '部门' },
    job_id: { type: 'many2one', string: '岗位' },
    // 设置管理员 后 查看权限问题
    // parent_id: { type: 'many2one', string: '管理员' }

    address_id: { type: 'many2one', string: '工作地址', popupselected: true },
    coach_id: { type: 'many2one', string: '教练' },

    address_home_id: {
      type: 'many2one',
      string: '家庭地址',
      popupselected: true
    },
    private_email: { type: 'char', related: true, string: 'Email' },
    phone: { type: 'char', related: true, string: '电话' },

    bank_account_id: {
      type: 'many2one',
      string: '银行账户号码',
      popupselected: true,
      fields: { display_name: null, partner_id: null },
      filter: ({ record, oldValue, newValue, options }) => {
        console.log('bank_account_id,', newValue.address_home_id, options)
        // 只能选 持有人 为 address_home_id 的 银行账户
        return options.filter(item => {
          return item.object.partner_id === newValue.address_home_id
        })
      }
    },
    km_home_work: { type: 'integer', string: '家与公司相距公里数' },
    country_id: { type: 'many2one', string: '国籍', popupselected: true },
    identification_id: { type: 'char', string: '身份证号' },
    passport_id: { type: 'char', string: '护照号' },
    gender: { type: 'selection', string: '性别' },
    birthday: {
      type: 'date',
      string: '出生日期',
      min_date: new Date(1900, 1, 1),
      max_date: new Date()
    },
    place_of_birth: { type: 'char', string: '出生地' },
    country_of_birth: {
      type: 'many2one',
      string: '出生地国家',
      popupselected: true
    },

    marital: {
      selection: { cohabitant: '其他' },
      type: 'selection',
      string: '婚姻状况'
    },
    children: { type: 'integer', string: '子女数目' },
    emergency_contact: { type: 'char', string: '紧急联系人' },
    emergency_phone: { type: 'char', string: '紧急联系电话' },
    visa_no: { type: 'char', string: '签证号' },
    permit_no: { type: 'char', string: '工作证编号' },
    visa_expire: { type: 'date', string: '签证到期日期' },
    certificate: {
      selection: { bachelor: '本科', master: '研究生', other: '其他' },
      type: 'selection',
      string: '最后学历'
    },
    study_field: { type: 'char', string: '专业' },
    study_school: { type: 'char', string: '学校' },

    user_id: { type: 'many2one', string: '相关用户', popupselected: true },
    barcode: { type: 'char', string: '工牌 ID' }
  },
  metadata: {
    propForView: {
      fields: {
        name: null,
        mobile_phone: null,
        work_phone: null,
        work_email: null,
        work_location: null,
        department_id: null,
        job_id: null
      },
      notebook: {
        default: 'public',
        pages: [
          {
            name: 'public',
            label: '工作信息',
            fields: {
              address_id: null,
              coach_id: null
            }
          },
          {
            name: 'personal_information',
            label: '个人隐私信息',
            fields: {
              address_home_id: null,
              private_email: null,
              phone: null,
              bank_account_id: null,
              km_home_work: null,
              country_id: null,
              identification_id: null,
              passport_id: null,
              gender: null,
              birthday: null,
              place_of_birth: null,
              country_of_birth: null,
              marital: null,
              children: null,
              emergency_contact: null,
              emergency_phone: null,
              visa_no: null,
              permit_no: null,
              visa_expire: null,
              certificate: null,
              study_field: null,
              study_school: null
            }
          },
          {
            name: 'hr_settings',
            label: 'HR',
            fields: {
              user_id: null,
              barcode: null
            }
          }
        ]
      }
    },
    propForList: {
      // title: rec => {
      //   return `${rec.code} ${rec.display_name}`
      // },
      // icon: rec => {
      //   return get_image('res.country', rec.id, 'image')
      // },
      // label: rec => {
      //   return ``
      // },
      // value: rec => {
      //   return ``
      // }
    }
  }
}

const Models = {
  'hr.employee': HrEmployee
}

export default Models
